/* Error Messages */
var ERR_MSG_MUST_IMPLEMENT = "You must implement this method!"

/* Names & Defines */
var NAME_REQ_TYPE_SYNC = 'SYNC';
var NAME_REQ_TYPE_ASYNC_IGNR = 'ASYNC_IGNR';
var NAME_REQ_TYPE_ASYNC_MNGD = 'ASYNC_MNGD';
var DEF_REQ_QUEUE_MAX_COUNT = 10;
var DEF_REQ_QUEUE_TIMER_INTERVAL = 10; // seconds
var DEF_REQ_URL = '/swacd/html/response.html';
var DEF_OBJ_TIMER_INTERVAL = 10;
//var DEF_OBJ_TIMER_INTERVAL = 30;

/* RAD Aliases */
var REQ_SYNC = NAME_REQ_TYPE_SYNC;
var REQ_AIGN = NAME_REQ_TYPE_ASYNC_IGNR;
var REQ_AMNG = NAME_REQ_TYPE_ASYNC_MNGD;

/**
	@class
	Utils Singleton.
	Métodos úteis/gerais do sistema.
*/
var Utils = new function ()
{
	this.isIE = Ext.isIE;
	this.isLeakerIE = /msie [3-6]/i.test (navigator.appVersion);

	this.cdataReg = new RegExp("]]>","g");

	this.dumpvar = function (obj)
	{
		var s=''; var i=0;
		for (var prop in obj) {
			s += prop + '=[' + obj[prop] + '],  ';
			if(++i == 4) { i=0; s+='\n'; }
		}
		return s;
	}

	this.alertvar = function (obj)
	{
		alert('alertvar:\n' + this.dumpvar(obj));
	}

	this.warn = function (msg, level)
	{
		alert (msg);
	}

	/* Copiado do V4 */

	this.nodeText = function (node) {
		if(!node) return;
		var children=node.childNodes;
		if(children){
			var textArr=[];
			// get elements value string
			var childrenLen=children.length;
			for(var i=0;i<childrenLen;i++){
				var child=children[i];
				var childNodeType=child.nodeType;
				if((childNodeType==3 || childNodeType==4) && child.nodeValue!=null) textArr.push(child.nodeValue); // text data
			}
			return textArr.join("");
		}
	}
}
